#include <51func.h>
#include <l8w8jwt/encode.h> // /usr/include

int main(void)
{
    char* jwt;
    size_t jwt_length;

    struct l8w8jwt_encoding_params params;
    l8w8jwt_encoding_params_init(&params);

    params.alg = L8W8JWT_ALG_HS512;

    params.sub = "Netdisk";
    params.iss = "Liao";
    params.aud = "User";

    params.iat = 0;
    params.exp = 0x7fffffff; 
    params.secret_key = (unsigned char*)"Lisi"; // secret_key 每个用户不同的内容
    params.secret_key_length = strlen(params.secret_key);
    params.out = &jwt;
    params.out_length = &jwt_length;

    int r = l8w8jwt_encode(&params);

    printf("token = %s\n", jwt); // jwt是输出的内容
    /* Always free the output jwt string! */
    l8w8jwt_free(jwt);

    return 0;
}
